/*
 * @Date: 2023-08-08 08:51:22
 * @LastEditors: lyx
 * @LastEditTime: 2023-12-04 16:41:35
 * @FilePath: \sup-mini-app\src\pages\index\index.tsx
 * @Description:
 */
import { View, Text, Map, Button } from "@tarojs/components";
import { AtButton, AtTextarea } from "taro-ui";
import { connect } from "react-redux";
import Banner from "@/components/Banner";
import Weather from "@/components/Weather";
import English from "@/components/Daily/English";
import useHome from "./hooks/useHome";
import Post from "@/components/Post";
import "./index.scss";
import { requirePlugin } from "@tarojs/taro";

const Index = () => {
  const homeInst = useHome();
  return (
    <View className="home">
      <Banner />
      <View className="home-top">
        <View className="at-row">
          <View className="at-col left">
            <English></English>
          </View>
          <View className="at-col right">
            <Weather></Weather>
          </View>
        </View>
      </View>

      <View className="home-top">
        <AtTextarea
          count={false}
          value={homeInst.inputState.inputValue}
          onChange={(e) => {
            homeInst.setInputState({
              inputValue: e,
            });
          }}
          maxLength={200}
          placeholder="你的问题是..."
        />
        <Button
          type="primary"
          onTouchStart={homeInst.touchStart}
          onTouchEnd={homeInst.touchEnd}
        >
          {homeInst.inputState.recordState ? "松开结束" : "按住说话"}
        </Button>
      </View>

      <View className="main">
        <Post list={homeInst?.postList}></Post>

        <AtButton
          type="primary"
          onClick={() => {
            homeInst?.handleClick?.({
              key: "gpt",
              url: "http://withme.lawlighty.top:3001/gpt",
              // url: "https://www.baidu.com/",
              text: "supGPT",
            });
          }}
        >
          web view 测试
        </AtButton>
      </View>
    </View>
  );
};
export default connect(({ home: { currentTag }, loading }) => ({
  ...currentTag,
  // loading: loading.models.home
  // loading: loading.effects['home']
}))(Index);
